<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    function clone(parent, child) {
      // 这里改用Object.create就可以减少组合继承中多进行一次构造的过程
      child.prototype = Object.create(parent.prototype);
      child.prototype.constructor = child;
    }
    function Parent6() {
      this.name = 'parent6';
      this.play = [1, 2, 3];
    }
    Parent6.prototype.getName = function () {
      return this.name;
    };
    function Child6() {
      Parent6.call(this);
      this.friends = 'child5';
    }
    clone(Parent6, Child6);
    Child6.prototype.getFriedns = function () {
      return this.friends;
    };
    let person6 = new Child6();
    console.log(person6);
    console.log(person6.getName());
    console.log(person6.getFriends());
  </script>
</html>
